<?php
declare(strict_types=1);
namespace Field;

class SysAlbumAttachConst
{
    public const pk='AttachID';
    public const index=['AttachID'];
	public const fields=['AttachID','Name','Patch','Spec','CreateAt','UpdateAt','AlbumID','TypeID','UserID','Ext'];
	public const comment=['AttachID'=>'主键','Name'=>'文件名','Patch'=>'路径','Spec'=>'规格','CreateAt'=>'','UpdateAt'=>'更新时间','AlbumID'=>'相册id','TypeID'=>'1 图片 2 视频 3压缩包 enum','UserID'=>'上传会员ID','Ext'=>'扩展名'];
	/*
    * @Field AttachID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra auto_increment
    * @Privileges select,insert,update,references
    * @Comment 主键
    */
    public const AttachID = 'AttachID';
    /*
    * @Field Name
    * @Type varchar(64)
    * @Collation utf8mb4_general_ci
    * @Null NO
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 文件名
    */
    public const Name = 'Name';
    /*
    * @Field Patch
    * @Type varchar(64)
    * @Collation utf8mb4_general_ci
    * @Null NO
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 路径
    */
    public const Patch = 'Patch';
    /*
    * @Field Spec
    * @Type varchar(32)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 规格
    */
    public const Spec = 'Spec';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const CreateAt = 'CreateAt';
    /*
    * @Field UpdateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra on update CURRENT_TIMESTAMP
    * @Privileges select,insert,update,references
    * @Comment 更新时间
    */
    public const UpdateAt = 'UpdateAt';
    /*
    * @Field AlbumID
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 1
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 相册id
    */
    public const AlbumID = 'AlbumID';
    /*
    * @Field TypeID
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 1
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 1 图片 2 视频 3压缩包 enum
    */
    public const TypeID = 'TypeID';
    /*
    * @Field UserID
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 上传会员ID
    */
    public const UserID = 'UserID';
    /*
    * @Field Ext
    * @Type varchar(8)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 扩展名
    */
    public const Ext = 'Ext';
}

class SysAlbumAttachColumns
{
public  int $AttachID;
   public  string $Name;
   public  string $Patch;
   public  ?string $Spec='';
   public  ?string $CreateAt='';
   public  ?string $UpdateAt='';
   public  int $AlbumID=0;
   public  int $TypeID=0;
   public  int $UserID=0;
   public  ?string $Ext='';
	public function toArray():array
	{
		return [
'AttachID'=>$this->AttachID,
    'Name'=>$this->Name,
    'Patch'=>$this->Patch,
    'Spec'=>$this->Spec,
    'CreateAt'=>$this->CreateAt,
    'UpdateAt'=>$this->UpdateAt,
    'AlbumID'=>$this->AlbumID,
    'TypeID'=>$this->TypeID,
    'UserID'=>$this->UserID,
    'Ext'=>$this->Ext,        ];
	}
}

class SysAlbumAttachRow
{
	public SysAlbumAttachColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'AttachID' => $this->data->AttachID,
        'Name' => $this->data->Name,
        'Patch' => $this->data->Patch,
        'Spec' => $this->data->Spec,
        'CreateAt' => $this->data->CreateAt,
        'UpdateAt' => $this->data->UpdateAt,
        'AlbumID' => $this->data->AlbumID,
        'TypeID' => $this->data->TypeID,
        'UserID' => $this->data->UserID,
        'Ext' => $this->data->Ext, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new SysAlbumAttachColumns();
        isset($data['AttachID']) && $this->data->AttachID = (int)$data['AttachID'];
           isset($data['Name']) && $this->data->Name = (string)$data['Name'];
           isset($data['Patch']) && $this->data->Patch = (string)$data['Patch'];
           isset($data['Spec']) && $this->data->Spec = (string)$data['Spec'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
           isset($data['UpdateAt']) && $this->data->UpdateAt = (string)$data['UpdateAt'];
           isset($data['AlbumID']) && $this->data->AlbumID = (int)$data['AlbumID'];
           isset($data['TypeID']) && $this->data->TypeID = (int)$data['TypeID'];
           isset($data['UserID']) && $this->data->UserID = (int)$data['UserID'];
           isset($data['Ext']) && $this->data->Ext = (string)$data['Ext'];
    }
}
?>